/**
 * 数据库相关配置
 */

// 导入sequelize
const { Sequelize } = require('sequelize');

// 实例化对象
const sequelize = new Sequelize(
  'db_library',
  'library',
  'Bigdata@123',
  {
    host: '192.168.56.102',
    port: '26000',  // 端口
    dialect: 'postgres',
    dialectOptions: {
      //字符集
      charset: 'utf8mb4',
      collate: 'utf8mb4_unicode_ci',
      supportBigNumbers: true,
      bigNumberStrings: true
    },
    pool: {
      max: 5,
      min: 0,
      acquire: 30000,
      idle: 10000
    },
    timezone: '+08:00'  //东八时区
  });

// 测试数据库的连接
// sequelize
//   .authenticate()
//   .then(() => {
//     console.log('数据库连接成功.');
//   })
//   .catch((error) => {
//     console.error('数据库连接失败:', error);
//   });

// 导出数据库的连接对象
module.exports = sequelize;
